/*
 * Created by Christopher King
 * Copyright (C) 2007 Christopher King, All Rights Reserved.
 */

package us.cirion.adventure.engine.result;

import us.cirion.adventure.engine.ItemLocation;
import us.cirion.adventure.engine.Noun;
import us.cirion.adventure.engine.Result;

/**
 * Moves an item to a specified location. The item may already exist in another
 * location, or it may not currently exist anywhere. Any valid location may be
 * set, including a player's inventory.
 * 
 * @author Chris
 */
public class SetItemLocation implements Result
{

	private Noun item;
	private ItemLocation newLocation;

	/**
	 * Constructs a new command to place the item.
	 * 
	 * @param item The item to relocate.
	 * @param newLocation The new location of the item.
	 */
	public SetItemLocation(Noun item, ItemLocation newLocation)
	{
		this.item = item;
		this.newLocation = newLocation;
	}

	/**
	 * Places the item.
	 */
	public void execute()
	{
		// This function will automatically remove the item from an existing
		// location,
		// if necessary.
		newLocation.addItem(item);
	}

}
